import Vue from 'vue'
import Router from 'vue-router'
import VueResource from 'vue-resource';//ajax .$http对象

import index from '@/components/index/index.vue'
import player from '@/components/player/player.vue'
import team from '@/components/team/team.vue'
import teamlist from '@/components/team/teamlist.vue'
import navi from '@/components/public/navi/navi.vue'
import myheader from '@/components/public/header/myheader.vue'
import banner from '@/components/public/banner/banner.vue'
import login from '@/components/public/login.vue'
import userReg from '@/components/user/reg.vue'
import expert from '@/components/expert/expert.vue'
import member from '@/components/member/member.vue'
import teamInfo from '@/components/team/teamInfo.vue'
import teamMatch from '@/components/team/teamMatch.vue'



Vue.use(Router)
Vue.use(VueResource)


export default new Router({
  meta: {
    requireAuth: true, // 添加该字段，表示进入这个路由是需要登录的
  },
  routes: [
    {
      path: '/',
      name: 'index',
      component: index
    },
    {
      path: '/player',
      name: 'player',
      component: player
    },
    {
      path: '/team',
      name: 'team',
      component: team
    },
    {
      path: '/navi',
      name: 'navi',//和其它vue引入匹配
      component: navi //和import相应
    }
    ,
    {
      path: '/myheader',
      name: 'myheader',//和其它vue引入匹配
      component: myheader //和import相应
    }
    ,{
      path: '/banner',
      name: 'banner',//和其它vue引入匹配
      component: banner //和import相应
    },{
      path: '/teamlist',
      name: 'teamlist',
      component: teamlist
    },{
      path: '/login',
      name: 'login',
      component: login
    },{
      path: '/user/reg',
      name: 'userReg',
      component: userReg
    }
    ,{
      path: '/expert',
      name: 'expert',
      component: expert,
      meta: {
        requireAuth: true,  // 添加该字段，表示进入这个模块路由是需要登录的
      }
    },
    {
      path: '/member',
      name: 'member',
      component: member,
      meta: {
        requireAuth: true,  // 添加该字段，表示进入这个模块路由是需要登录的
      }
    },
    {
      path: '/teamInfo',
      name: 'teamInfo',
      component: teamInfo
    },
    {
      path: '/teamMatch',
      name: 'teamMatch',
      component: teamMatch
    }

  ]
})

/*补充前后端 不同服务器跨域 报错 Uncaught(in promise)*/
const originalPush = Router.prototype.push
Router.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
}
